		$(document).ready(function(){			
			var  lid = getUrlParam('lid');
			var  like = "";
			
			//展示
			$.ajax({
				url:d + "/lifedetail",
				type:"POST",
				data:JSON.stringify({lid:lid}),
				contentType:'application/json;charset=utf-8',
				dataType:"json",
				success:function(data){
						var str=('<img src="img/red.png" width="20%"/><br>'+
								'<font size="5" color=""><b>'+data['life'].ltitle+'</b></font><br><br>'+
								'<font size="2" color="#737383">'+data['life'].ldate+'</font><br><br>'+
								data['life'].lcontent);
						var like=data['life'].lzan;
						$("#lcontent").append(str);
						$("#lcontent").trigger('create');
						$("#likeCount1").append(like);
						$("#likeCount1").trigger('create');
				},
				error:function(data){
//					alert("服务器繁忙");
				}
			});
	
	//点赞
	$('body').on("click",'.heart',function()
    {
    	var A=$(this).attr("id");
    	var B=A.split("like");
        var messageID=B[1];
        var like=parseInt($("#likeCount"+messageID).html());
    	$(this).css("background-position","")
        var D=$(this).attr("rel");
       
        if(D === 'like') 
        {      
        $("#likeCount"+messageID).html(like+1);
        $(this).addClass("heartAnimation").attr("rel","unlike");
        like++;
        }
        else
        {
        $("#likeCount"+messageID).html(like-1);
        $(this).removeClass("heartAnimation").attr("rel","like");
        $(this).css("background-position","left");
        like--;
        }

			$.ajax({
				url:d+"/lifezan",
				type:"POST",
				data:JSON.stringify({lid:lid,lzan:like}),
				contentType:'application/json;charset=utf-8',
//				dataType:"json",
				success:function(data){

				},
				error:function(data){
					alert("服务器繁忙");
				}
			});		
    });		


    	//显示评论
			$.ajax({
				type:"POST",
				url:d+"/lrlist",
				data:JSON.stringify({lid:lid}),
				contentType:'application/json;charset=utf-8',
				dataType:"json",
				success:function(data){
					for(var i=0;i<data['review'].length;i++){
						var str=('<li data-icon="false">'+
						'<font size="4" color="#22C3AA"><b>游客</b></font><br>'+
						'<font size="4" color="#000000"><p>'+data['review'][i].rcontent+'</p></font>'+
						'</li>');
						$("#rlist").append(str);
						$("#rlist").listview('refresh');
					}
				},
				error:function(data){
					//alert("服务器繁忙");
				}
			});
			
			
    	//发送评论
			$("#sendit").on("click",function(){
				$.ajax({
					type:"POST",
					url:d+"/lrsend",
					data:JSON.stringify({lid:lid,rcontent:$('#rset textarea').val()}),
					contentType:'application/json;charset=utf-8',
					success:function(data){
						alert("评论成功");
					},
					error:function(data){
						
					}
				});
			});
});